<template>
	<view>
		<image class="wenhao" src="../../static/wenhao.png"></image>
		<button class="dl" @click="olgin">登录</button>
		<view class="border"></view>
		<view class="sc">
			收藏:
		</view>
		
		<view class="nothingsc" v-if="this.addid.length == 0">暂无收藏</view>
		
		<view>
		<view class="item" @click="oneintering" v-if="this.oneaddscitem">
			<view class="story">
				<view class="title">{{oneaddscitem.title}}</view>
				<view class="con">{{oneaddscitem.hint}}</view>
			</view>
			<image :src="oneaddscitem.images[0]" :lazy-load="true" class="thumb"></image>
		</view>

		<view class="item" @click="twointering">
			<view class="story">
				<view class="title">{{twoaddscitem.title}}</view>
				<view class="con">{{twoaddscitem.hint}}</view>
			</view>
			<image :src="twoaddscitem.images[0]" :lazy-load="true" class="thumb"></image>
		</view>

		<view class="item" @click="threeintering">
			<view class="story">
				<view class="title">{{threeaddscitem.title}}</view>
				<view class="con">{{threeaddscitem.hint}}</view>
			</view>
			<image :src="threeaddscitem.images[0]" :lazy-load="true" class="thumb"></image>
		</view>

		<view class="item" @click="fourintering">
			<view class="story">
				<view class="title">{{fouraddscitem.title}}</view>
				<view class="con">{{fouraddscitem.hint}}</view>
			</view>
			<image :src="fouraddscitem.images[0]" :lazy-load="true" class="thumb"></image>
		</view>

		<view class="item" @click="fiveintering">
			<view class="story">
				<view class="title">{{fiveaddscitem.title}}</view>
				<view class="con">{{fiveaddscitem.hint}}</view>
			</view>
			<image :src="fiveaddscitem.images[0]" :lazy-load="true" class="thumb"></image>
		</view>
		</view>

		<view class="five" v-if="this.addid.length==5">最多显示5条</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addscitem: null,
				oneaddscitem: null,
				twoaddscitem: null,
				threeaddscitem: null,
				fouraddscitem: null,
				fiveaddscitem: null,
				addlist: [],
				addid: [],
			};
		},
		onLoad(option) {
			let addid = uni.getStorageSync('addsc');
			console.log(addid)
			console.log(addid[0])
			this.addid = addid

			if (this.addid.length == 0) {
				return
			} else {
				if (this.addid.length == 1) {
					uni.request({
						url: "https://apis.netstart.cn/zhihudaily/story/" + addid,
						success: (res) => {
							this.oneaddscitem = res.data.story
						},
					})
				} else {

					uni.request({
						url: "https://apis.netstart.cn/zhihudaily/story/" + addid[0],
						success: (res) => {
							this.oneaddscitem = res.data.story
						},
					})

					if (this.addid.length == 2) {
						uni.request({
							url: "https://apis.netstart.cn/zhihudaily/story/" + addid[1],
							success: (res) => {
								this.twoaddscitem = res.data.story
							},
						})
					} else {
						return
					}

					if (this.addid.length == 3) {
						uni.request({
							url: "https://apis.netstart.cn/zhihudaily/story/" + addid[2],
							success: (res) => {
								this.threeaddscitem = res.data.story
							},
						})
					} else {
						return
					}

					if (this.addid.length == 4) {
						uni.request({
							url: "https://apis.netstart.cn/zhihudaily/story/" + addid[3],
							success: (res) => {
								this.fouraddscitem = res.data.story
							},
						})
					} else {
						return
					}

					if (this.addid.length == 5) {
						uni.request({
							url: "https://apis.netstart.cn/zhihudaily/story/" + addid[4],
							success: (res) => {
								this.fiveaddscitem = res.data.story
							},
						})
					} else {
						return
					}
				}
			}
		},

		methods: {
			oneintering() {
				uni.navigateTo({
					url: "../../pages/detail/detail?id=" + this.addid[0]
				})
			},
			twointering() {
				uni.navigateTo({
					url: "../../pages/detail/detail?id=" + this.addid[1]
				})
			},
			threeintering() {
				uni.navigateTo({
					url: "../../pages/detail/detail?id=" + this.addid[2]
				})
			},
			fourintering() {
				uni.navigateTo({
					url: "../../pages/detail/detail?id=" + this.addid[3]
				})
			},
			fiveintering() {
				uni.navigateTo({
					url: "../../pages/detail/detail?id=" + this.addid[4]
				})
			},
			olgin(){
				uni.navigateTo({
					url:"../login/login"
				})
			}
		}
	}
</script>

<style lang="less">
	.wenhao {
		width: 300rpx;
		height: 300rpx;
		display: block;
		margin: 0 auto;
	}

	.dl {
		border-radius: 10rpx;
		width: 400rpx;
		font-weight: bold;
		background-color: green;
		color: white;
	}

	.border{
		margin-top: 50rpx;
		border-top: 1px solid #e5e5e5;
	}
	.sc {
		margin-left: 50rpx;
		margin-top: 20rpx;
		color: #909399;
	}

	.item {
		// border: 1px solid #cbcbcb;
		display: flex;
		align-items: center;
		margin: 30rpx;
		border-radius: 20rpx;
		padding: 20rpx;


		.story {
			flex: 1;

			.title {
				font-size: 30rpx;
				font-weight: bold;
				max-width: 520rpx;
			}

			.con {
				font-size: 20rpx;
				color: #aaaaaa;
				line-height: 3em;
			}
		}

		.thumb {
			width: 120rpx;
			height: 120rpx;
			border-radius: 6rpx;

		}
	}

	.five {
		color: #909399;
		text-align: center;
		padding-bottom: 10rpx;
	}
	.nothingsc{
		text-align: center;
		color: #999;
		margin-top: 30%;
	}
</style>
